package com.lzw.mall.common.mapper;

import com.lzw.mall.common.entity.Member;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lizhenwei
 * @since 2023-03-23
 */
public interface MemberMapper extends BaseMapper<Member> {

    List<Member> selectListPage(String keyword, String sex, String status);

    @Select("select * from member where username=#{username}")
    Member selectByUsername(String username);

    @Select("select * from member where username=#{username} and id<>#{id}")
    List<Member> selectByUsernameAndId(String username, Integer id);

    @Update("update member set username=#{username},sex=#{sex},name=#{name},phone=#{phone},avatar=#{avatar} where id=#{id}")
    void doUpdateById(@Param("id") Integer id, @Param("username")  String username, @Param("sex")  String sex, @Param("name")  String name, @Param("phone")  String phone, @Param("avatar")  String avatar);

    @Select("select * from member where id=#{id}")
    Member doSelectById(Integer id);

    @Update("update member set password=#{password} where id=#{id}")
    void updatePassword(String password, Integer id);

    @Update("update member set password='e10adc3949ba59abbe56e057f20f883e' where id=#{id}")
    void updateMima(Integer id);

    void openMember(Integer[] ids);

    void closeMember(Integer[] ids);

    @Select("select * from member where phone = #{phone}")
    Member selectByPhone(String phone);

}
